<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 7.3.0">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.ico">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.ico">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha256-wiz7ZSCn/btzhjKDQBms9Hx4sSeUYsDrTLg7roPstac=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.css" integrity="sha256-6cQIC71/iBIYXFK+0RHAvwmjwWzkWd+r7v/BX3/vZDc=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/themes/green/pace-theme-minimal.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/pace.min.js" integrity="sha256-gqd7YTjg/BtfqWSwsJOvndl0Bxc8gFImLEkXQT8+qj0=" crossorigin="anonymous"></script>

<script class="next-config" data-name="main" type="application/json">{"hostname":"sumumm.github.io","root":"/","images":"/images","scheme":"Gemini","darkmode":false,"version":"8.19.2","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":{"enable":true,"style":"mac"},"fold":{"enable":true,"height":300},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":true,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":true,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>

    <meta name="description" content="本文主要是AES算法——AES算法基本原理的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:type" content="article">
<meta property="og:title" content="LV04-02-AES算法-01-AES算法基本原理">
<meta property="og:url" content="https://sumumm.github.io/post/914dd50d.html">
<meta property="og:site_name" content="苏木">
<meta property="og:description" content="本文主要是AES算法——AES算法基本原理的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240810100957523.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240812074842387.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240823075327904.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240817062647468.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240817063141047.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240817063951940.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240822074907843.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240820073919337.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240816075348961.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240820075017532.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240820225731801.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240820075855856.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240820230459937.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240820231532597.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/e2c06e75355a5646c48e9e34d6b6ae8c.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/3d2821753c987009467ee4bc32bd5d47.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/59a9189060c3282ac955e94998353c9d.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/3cd9fdef1e1047d154a8c11bcfb898fa.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240821070949198.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240821071859030.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240821072925306.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240821072902597.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240821073739426.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240822075011547.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240822075049267.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240822074321355.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240822074410571.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240822074457918.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240822074526335.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240822075251313.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240822075634528.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240824064237513.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240824070820815.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/ECB_working_mode.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/CBC_working_mode.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/CTR_working_mode.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/CFB_working_mode.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/OFB_working_mode.png">
<meta property="article:published_time" content="2024-08-25T05:47:42.000Z">
<meta property="article:modified_time" content="2025-06-13T16:25:57.064Z">
<meta property="article:author" content="苏木">
<meta property="article:tag" content="(ALPHA)LV04-加密与解密">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240810100957523.png">


<link rel="canonical" href="https://sumumm.github.io/post/914dd50d.html">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":"","permalink":"https://sumumm.github.io/post/914dd50d.html","path":"post/914dd50d.html","title":"LV04-02-AES算法-01-AES算法基本原理"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>LV04-02-AES算法-01-AES算法基本原理 | 苏木</title>
  








    <script src="/js/browser_tools_disable.js"></script>

  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
<!-- hexo injector head_end start --><link rel="stylesheet" href="https://unpkg.com/hexo-next-tags-plus@latest/lib/tag_plus.css" media="defer" onload="this.media='all'"><!-- hexo injector head_end end --></head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">苏木</p>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">我的学习之路</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>苏木的家</a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类页<span class="badge">42</span></a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档页<span class="badge">673</span></a></li><li class="menu-item menu-item-flink"><a href="/flink/" rel="section"><i class="fa fa-link fa-fw"></i>友人帐</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于我</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%80%E3%80%81AES%E5%8A%A0%E5%AF%86%E7%AE%97%E6%B3%95%E7%AE%80%E4%BB%8B"><span class="nav-text">一、AES加密算法简介</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E7%AE%80%E4%BB%8B"><span class="nav-text">1. 简介</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-AES%E5%AE%89%E5%85%A8%E6%80%A7"><span class="nav-text">2. AES安全性</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#2-1-%E5%AE%89%E5%85%A8%E6%80%A7%E5%88%86%E6%9E%90"><span class="nav-text">2.1 安全性分析</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-2-%E6%8A%97%E6%94%BB%E5%87%BB%E6%80%A7%E8%83%BD"><span class="nav-text">2.2 抗攻击性能</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-AES%E5%9C%A8%E8%BD%AF%E7%A1%AC%E4%BB%B6%E7%9A%84%E5%AE%9E%E7%8E%B0"><span class="nav-text">3. AES在软硬件的实现</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BA%8C%E3%80%81AES%E5%8A%A0%E5%AF%86%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86"><span class="nav-text">二、AES加密算法基本原理</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86"><span class="nav-text">1. 基础知识</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-1-%E8%BE%93%E5%85%A5%E5%92%8C%E8%BE%93%E5%87%BA"><span class="nav-text">1.1 输入和输出</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-2-%E7%8A%B6%E6%80%81-State"><span class="nav-text">1.2 状态(State) </span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-3-%E5%8A%A0%E8%A7%A3%E5%AF%86%E5%87%BD%E6%95%B0"><span class="nav-text">1.3 加解密函数</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-AES%E7%AE%97%E6%B3%95%E6%B5%81%E7%A8%8B"><span class="nav-text">2. AES算法流程</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-%E5%8A%A0%E5%AF%86%E6%AD%A5%E9%AA%A4%E5%88%86%E6%9E%90"><span class="nav-text">3. 加密步骤分析</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#3-1-%E5%AD%97%E8%8A%82%E6%9B%BF%E4%BB%A3-SubBytes-%E5%8F%98%E6%8D%A2"><span class="nav-text">3.1 字节替代(SubBytes( ))变换 </span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-2-%E8%A1%8C%E7%A7%BB%E4%BD%8D-ShiftRows-%E5%8F%98%E6%8D%A2"><span class="nav-text">3.2 行移位(ShiftRows( ))变换</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-3-%E5%88%97%E6%B7%B7%E5%90%88-MixColumns-%E5%8F%98%E6%8D%A2"><span class="nav-text">3.3 列混合(MixColumns( ))变换</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-4-%E8%BD%AE%E5%AF%86%E9%92%A5%E5%8A%A0-AddRoundKey-%E5%8F%98%E6%8D%A2"><span class="nav-text">3.4 轮密钥加(AddRoundKey( ))变换 </span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-5-%E5%AF%86%E9%92%A5%E6%89%A9%E5%B1%95"><span class="nav-text">3.5 密钥扩展</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-%E8%A7%A3%E5%AF%86%E6%AD%A5%E9%AA%A4%E5%88%86%E6%9E%90"><span class="nav-text">4. 解密步骤分析</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#4-1-%E9%80%86%E8%A1%8C%E7%A7%BB%E4%BD%8D-InvShiftRows-%E5%8F%98%E6%8D%A2"><span class="nav-text">4.1 逆行移位(InvShiftRows( ))变换 </span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4-2-%E9%80%86%E5%AD%97%E8%8A%82%E6%9B%BF%E4%BB%A3-InvSubBytes-%E5%8F%98%E6%8D%A2"><span class="nav-text">4.2 逆字节替代(InvSubBytes( ))变换 </span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4-3-%E9%80%86%E5%88%97%E6%B7%B7%E5%90%88-InvMixColumns-%E5%8F%98%E6%8D%A2"><span class="nav-text">4.3 逆列混合(InvMixColumns( ))变换</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4-4-%E8%BD%AE%E5%AF%86%E9%92%A5%E5%8A%A0-AddRoundKey-%E5%8F%98%E6%8D%A2%E7%9A%84%E9%80%86%E5%8F%98%E6%8D%A2"><span class="nav-text">4.4 轮密钥加(AddRoundKey())变换的逆变换 </span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4-5-%E7%AD%89%E4%BB%B7%E7%9A%84%E8%A7%A3%E5%AF%86%E5%8F%98%E6%8D%A2"><span class="nav-text">4.5 等价的解密变换</span></a></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%89%E3%80%81%E5%8A%A0%E5%AF%86%E6%A8%A1%E5%BC%8F"><span class="nav-text">三、加密模式</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-AES%E5%A1%AB%E5%85%85%E6%96%B9%E5%BC%8F"><span class="nav-text">1. AES填充方式</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E5%8A%A0%E5%AF%86%E6%A8%A1%E5%BC%8F"><span class="nav-text">2. 加密模式</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#2-1-ECB-%E6%A8%A1%E5%BC%8F"><span class="nav-text">2.1 ECB 模式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-2-CBC-%E6%A8%A1%E5%BC%8F"><span class="nav-text">2.2 CBC 模式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-3-CTR-%E6%A8%A1%E5%BC%8F"><span class="nav-text">2.3 CTR 模式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-4-CFB-%E6%A8%A1%E5%BC%8F"><span class="nav-text">2.4 CFB 模式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-5-OFB%E6%A8%A1%E5%BC%8F"><span class="nav-text">2.5 OFB模式</span></a></li></ol></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="苏木"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">苏木</p>
  <div class="site-description" itemprop="description">莫道桑榆晚，为霞尚满天</div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">673</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">42</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">43</span>
        <span class="site-state-item-name">标签</span>
      </div>
  </nav>
</div>
  <div class="links-of-author animated">
      <span class="links-of-author-item">
        <a href="https://github.com/sumumm" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;sumumm" rel="noopener me" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>

        </div>
      </div>
    </div>

    
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://sumumm.github.io/post/914dd50d.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="苏木">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏木">
      <meta itemprop="description" content="莫道桑榆晚，为霞尚满天">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="LV04-02-AES算法-01-AES算法基本原理 | 苏木">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          LV04-02-AES算法-01-AES算法基本原理
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2024-08-25 13:47:42" itemprop="dateCreated datePublished" datetime="2024-08-25T13:47:42+08:00">2024-08-25</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/" itemprop="url" rel="index"><span itemprop="name">嵌入式开发</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/" itemprop="url" rel="index"><span itemprop="name">04音视频</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/" itemprop="url" rel="index"><span itemprop="name">LV04-加密与解密</span></a>
        </span>
    </span>

  
    <span class="post-meta-break"></span>
    <span class="post-meta-item" title="本文字数">
      <span class="post-meta-item-icon">
        <i class="far fa-file-word"></i>
      </span>
      <span class="post-meta-item-text">本文字数：</span>
      <span>12k</span>
    </span>
    <span class="post-meta-item" title="阅读时长">
      <span class="post-meta-item-icon">
        <i class="far fa-clock"></i>
      </span>
      <span class="post-meta-item-text">阅读时长 &asymp;</span>
      <span>44 分钟</span>
    </span>
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody"><p>本文主要是AES算法——AES算法基本原理的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。</p>
<span id="more"></span>

<!-- Photo: https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/ -->

<details class="folding-tag" blue><summary> 点击查看使用工具及版本 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center" rowspan="5">PC端开发环境</td>        <td align="center" width=150px>Windows</td>        <td align="left">Windows11</td>    </tr>    <tr>        <td align="center">Ubuntu</td>        <td align="left">Ubuntu20.04.6的64位版本</td>      </tr>    <tr>        <td align="center">VMware® Workstation 17 Pro</td>        <td align="left">17.0.0 build-20800274</td>      </tr>    <tr>        <td align="center">终端软件</td>        <td align="left">MobaXterm(Professional Edition v23.0 Build 5042 (license))</td>    </tr>    <tr>        <td align="center">Win32DiskImager</td>        <td align="left">Win32DiskImager v1.0</td>      </tr>    <tr>        <td align="center" rowspan="3">Linux开发板环境</td>        <td align="center">Linux开发板</td>        <td align="left">正点原子 i.MX6ULL Linux 阿尔法开发板</td>      </tr>    <tr>        <td align="center">uboot</td>        <td align="left">NXP官方提供的uboot，NXP提供的版本为uboot-imx-rel_imx_4.1.15_2.1.0_ga(使用的uboot版本为U-Boot 2016.03)</td>      </tr>    <tr>        <td align="center">linux内核</td>        <td align="left">linux-4.15(NXP官方提供)</td>      </tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看本文参考资料 </summary>
              <div class='content'>
              <ul><li>通用</li></ul><table>    <tr><td align="center">参考资料  </td><td align="center">相关链接</td></tr>    <tr><td align="left" rowspan=2>FIPS197</td><td align="left"><a href="https://csrc.nist.gov/files/pubs/fips/197/final/docs/fips-197.pdf" target="_blank">高级加密标准AES-FIPS197英文版<i class="fa fa-external-link-alt"></i> </a></td></tr>    <tr><td align="left"><a href="https://www.masol7.com/wp-content/uploads/2023/03/高级加密标准AES-FIPS197中文版.pdf" target="_blank">高级加密标准AES-FIPS197中文版<i class="fa fa-external-link-alt"></i> </a></td></tr>    <tr><td align="left" rowspan=1>一个相关的资料</td><td align="left"><a href="https://xilinx.github.io/Vitis_Libraries/security/2020.1/guide_L1/internals/aes.html" target="_blank">xilinx.github.io/Vitis_Libraries/security/2020.1/guide_L1/internals/aes.html<i class="fa fa-external-link-alt"></i> </a></td></tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看相关文件下载 </summary>
              <div class='content'>
              <table>    <tr><td align="left"><a href="" target="_blank">---</a></td><td align="left">---</td></tr></table>
              </div>
            </details>

<h1 id="一、AES加密算法简介"><a href="#一、AES加密算法简介" class="headerlink" title="一、AES加密算法简介"></a><font size=3>一、AES加密算法简介</font></h1><h2 id="1-简介"><a href="#1-简介" class="headerlink" title="1. 简介"></a><font size=3>1. 简介</font></h2><p><strong>高级加密标准</strong>（英语：<strong>A</strong>dvanced <strong>E</strong>ncryption <strong>S</strong>tandard，<a target="_blank" rel="noopener" href="https://www.wikiwand.com/zh-cn/%E7%BC%A9%E5%86%99">缩写</a>：AES），又称<strong>Rijndael加密法</strong>（荷兰语发音：[<a target="_blank" rel="noopener" href="https://www.wikiwand.com/zh-cn/Help:%E8%8D%B7%E8%98%AD%E8%AA%9E%E5%9C%8B%E9%9A%9B%E9%9F%B3%E6%A8%99">ˈrɛindaːl]</a>，音似英文的“Rhine doll”），是<a target="_blank" rel="noopener" href="https://www.wikiwand.com/zh-cn/%E7%BE%8E%E5%9B%BD%E8%81%94%E9%82%A6%E6%94%BF%E5%BA%9C">美国联邦政府</a>采用的一种<a target="_blank" rel="noopener" href="https://www.wikiwand.com/zh-cn/%E5%8D%80%E5%A1%8A%E5%8A%A0%E5%AF%86">区块加密</a>标准。这个标准用来替代原先的<a target="_blank" rel="noopener" href="https://www.wikiwand.com/zh-cn/DES">DES</a>，已经被多方分析且广为全世界所使用。经过五年的甄选流程，高级加密标准由<a target="_blank" rel="noopener" href="https://www.wikiwand.com/zh-cn/%E7%BE%8E%E5%9B%BD%E5%9B%BD%E5%AE%B6%E6%A0%87%E5%87%86%E4%B8%8E%E6%8A%80%E6%9C%AF%E7%A0%94%E7%A9%B6%E9%99%A2">美国国家标准与技术研究院</a>（NIST）于2001年11月26日发布于FIPS PUB 197，并在2002年5月26日成为有效的标准。现在，高级加密标准已然成为<a target="_blank" rel="noopener" href="https://www.wikiwand.com/zh-cn/%E5%AF%B9%E7%A7%B0%E5%AF%86%E9%92%A5%E5%8A%A0%E5%AF%86">对称密钥加密</a>中最流行的<a target="_blank" rel="noopener" href="https://www.wikiwand.com/zh-cn/%E6%BC%94%E7%AE%97%E6%B3%95">算法</a>之一。</p>
<p>它是一种分组加密标准，每个加密块大小为128位，允许的密钥长度为128、192和256位。它是一种<strong>对称加密算法</strong>，它是目前应用最广泛的加密算法之一。AES算法具有高效性、安全性和可靠性，被广泛用于数据保护、网络通信以及安全传输等领域。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240810100957523.png" alt="image-20240810100957523" style="zoom:50%;" />

<h2 id="2-AES安全性"><a href="#2-AES安全性" class="headerlink" title="2. AES安全性"></a><font size=3>2. AES安全性</font></h2><h3 id="2-1-安全性分析"><a href="#2-1-安全性分析" class="headerlink" title="2.1 安全性分析"></a><font size=3>2.1 安全性分析</font></h3><ul>
<li><strong>轮数与密钥长度</strong></li>
</ul>
<p>AES为分组密码，分组密码也就是把明文分成一组一组的，每组长度相等，每次加密一组数据，直到加密完整个明文。在AES标准规范中，分组长度只能是128位，也就是说，每个分组为16个字节（每个字节8位）。密钥的长度可以使用128位、192位或256位。密钥的长度不同，推荐加密轮数也不同，如下表所示：</p>
<table>
<thead>
<tr>
<th align="center">AES</th>
<th align="center">密钥长度（32位比特字)</th>
<th align="center">分组长度(32位比特字)</th>
<th align="center">加密轮数</th>
</tr>
</thead>
<tbody><tr>
<td align="center">AES-128</td>
<td align="center">4</td>
<td align="center">4</td>
<td align="center">10</td>
</tr>
<tr>
<td align="center">AES-192</td>
<td align="center">6</td>
<td align="center">4</td>
<td align="center">12</td>
</tr>
<tr>
<td align="center">AES-256</td>
<td align="center">8</td>
<td align="center">4</td>
<td align="center">14</td>
</tr>
</tbody></table>
<p>一般来说，密钥长度越长，破解难度越大，安全性越高。推荐使用256位密钥以获得最高级别的安全性。AES的安全性与轮数有关，一般128位密钥对应10轮，192位密钥对应12轮，256位密钥对应14轮。增加轮数可以增强加密算法的安全性，但也会增加计算成本。</p>
<blockquote>
<p>选择AES的密钥长度时，应根据所需的安全级别和性能需求来决定：</p>
<p>（1）对于一般应用，128位密钥已经足够安全，而且具有较好的性能表现。</p>
<p>（2）如果需要更高级别的安全性，可以选择192位或256位密钥。256位密钥提供了最高级别的安全性，但会增加加密和解密的计算成本。</p>
<p>（3）在实际应用中，应权衡安全性和性能需求，选择合适的密钥长度。</p>
</blockquote>
<ul>
<li><strong>S盒设计</strong></li>
</ul>
<p>AES的S盒（Substitution Box）经过专门设计，具有良好的非线性性和扩散性，增强了AES的安全性。S盒的设计是AES抵抗差分攻击和线性攻击的关键。</p>
<blockquote>
<p>S盒是什么？<a target="_blank" rel="noopener" href="https://omni.wikiwand.com/zh/articles/S%E7%9B%92">S盒 - Wikiwand &#x2F; articles</a></p>
<p>在密码学中，一个S盒（Substitution-box，替换盒）是对称密钥加密算法执行替换计算的基本结构。在块密码中，它们通常用于模糊密钥与密文之间的关系——香农的混淆理论。</p>
<p>通常，S-Box接受特定数量的输入比特m，并将其转换为特定数量的输出比特n，其中n 不一定等于m。一个m×n的S盒可以通过包含2m条目，每条目n比特的查找表实现。S盒通常是固定的（例如DES和AES加密算法）, 也有一些加密算法的S盒是基于密钥动态生成的（例如Blowfish和双鱼算法加密算法）。DES的6×4位S盒（S5）是一个很好的例子：</p>
<table>
    <tr>
    <th rowspan="2" colspan="2">S<sub>5</sub></th>
    <th colspan="16" align="center">中间四个比特
    </th></tr>
    <tr>
    <th>0000</th>
    <th>0001</th>
    <th>0010</th>
    <th>0011</th>
    <th>0100</th>
    <th>0101</th>
    <th>0110</th>
    <th>0111</th>
    <th>1000</th>
    <th>1001</th>
    <th>1010</th>
    <th>1011</th>
    <th>1100</th>
    <th  >1101</th>
    <th>1110</th>
    <th>1111
    </th></tr>
    <tr>
    <th rowspan="4">首尾比特
    </th>
    <th>00
    </th>
    <td>0010</td>
    <td>1100</td>
    <td>0100</td>
    <td>0001</td>
    <td>0111</td>
    <td>1010</td>
    <td>1011</td>
    <td>0110</td>
    <td>1000</td>
    <td>0101</td>
    <td>0011</td>
    <td>1111</td>
    <td>1101</td>
    <td >0000</td>
    <td>1110</td>
    <td>1001
    </td></tr>
    <tr>
    <th>01
    </th>
    <td >1110</td>
    <td >1011</td>
    <td >0010</td>
    <td >1100</td>
    <td >0100</td>
    <td >0111</td>
    <td >1101</td>
    <td >0001</td>
    <td >0101</td>
    <td >0000</td>
    <td >1111</td>
    <td >1010</td>
    <td >0011</td>
    <td >1001</td>
    <td >1000</td>
    <td >0110
    </td></tr>
    <tr>
    <th>10
    </th>
    <td>0100</td>
    <td>0010</td>
    <td>0001</td>
    <td>1011</td>
    <td>1010</td>
    <td>1101</td>
    <td>0111</td>
    <td>1000</td>
    <td>1111</td>
    <td>1001</td>
    <td>1100</td>
    <td>0101</td>
    <td>0110</td>
    <td >0011</td>
    <td>0000</td>
    <td>1110
    </td></tr>
    <tr>
    <th>11
    </th>
    <td>1011</td>
    <td>1000</td>
    <td>1100</td>
    <td>0111</td>
    <td>0001</td>
    <td>1110</td>
    <td>0010</td>
    <td>1101</td>
    <td>0110</td>
    <td>1111</td>
    <td>0000</td>
    <td>1001</td>
    <td>1010</td>
    <td >0100</td>
    <td>0101</td>
    <td>0011
    </td></tr>
</table>

<p>给定6比特输入，将首尾两个比特作为行条件、中间四个比特（inner four bits）作为列条件进行查表，最终获得4比特输出。例如，输入“011011”，通过首尾两个比特“01”和中间的比特“1101”进行查表，最终的输出应该是“1001”。</p>
</blockquote>
<ul>
<li><strong>密钥调度算法</strong></li>
</ul>
<p>AES使用密钥调度算法生成轮密钥，确保生成的轮密钥与原始密钥无关，增加了密码的复杂性，提高了安全性。</p>
<h3 id="2-2-抗攻击性能"><a href="#2-2-抗攻击性能" class="headerlink" title="2.2 抗攻击性能"></a><font size=3>2.2 抗攻击性能</font></h3><p>AES具有很好的抗攻击性能，主要表现在以下几个方面：</p>
<p><strong>差分攻击（Differential Cryptanalysis）：</strong> AES对差分攻击有较好的抵抗能力，这种攻击方式需要大量的明文-密文对来分析密码算法的性质，而AES的S盒设计和轮函数的复杂性使得差分攻击变得更加困难。</p>
<p><strong>线性攻击（Linear Cryptanalysis）：</strong> AES对线性攻击也有较好的抵抗能力，线性攻击利用线性逼近的特性来破解密码算法，AES的设计使得线性攻击难以成功。</p>
<h2 id="3-AES在软硬件的实现"><a href="#3-AES在软硬件的实现" class="headerlink" title="3. AES在软硬件的实现"></a><font size=3>3. AES在软硬件的实现</font></h2><p>AES可以在软件和硬件中实现，提供数据加密和解密功能。在软件中，AES通常通过调用加密库或使用加密算法实现。在硬件中，AES可以通过专用的加密芯片或FPGA实现加速加密运算。</p>
<p>在软件中实现AES时，可以使用各种编程语言（如C、C++、Java等）提供的加密库，或者使用开源的加密算法库（如OpenSSL、Crypto++等）来实现AES算法。</p>
<p>在硬件中实现AES时，可以使用专门设计的加密芯片（如TPM芯片）或者使用FPGA（现场可编程门阵列）来加速AES加密运算。硬件实现通常能提供更高的性能和安全性，适用于对加密性能要求较高的场景。</p>
<h1 id="二、AES加密算法基本原理"><a href="#二、AES加密算法基本原理" class="headerlink" title="二、AES加密算法基本原理"></a><font size=3>二、AES加密算法基本原理</font></h1><h2 id="1-基础知识"><a href="#1-基础知识" class="headerlink" title="1. 基础知识"></a><font size=3>1. 基础知识</font></h2><h3 id="1-1-输入和输出"><a href="#1-1-输入和输出" class="headerlink" title="1.1 输入和输出"></a><font size=3>1.1 输入和输出</font></h3><p>AES 算法的输入和输出均为一个长度为128的比特串（值为0或1）。这些序列也可以 称为分组(blocks)，其中含有的位(bits)数也称为分组长度。</p>
<p>AES算法的密钥是128,192或256  比特的序列。AES-FIPS197标准中不允许其它的输入、输出长度和密钥长度。  序列中比特的编号从0开始，至序列长度(分组长度或密钥长度)减1。将该比特的编号 i 称为其索引。根据分组长度和密钥长度决定其值属于下列范围中的哪一个： $0 \leq i \lt 128$,  $0 \leq i \lt 192$或$0 \leq i \lt 256$。</p>
<p>AES加密过程涉及到4种操作，分别是字节替代、行移位、列混合和轮密钥加。解密过程分别为对应的逆操作。由于每一步操作都是可逆的，按照相反的顺序进行解密即可恢复明文。加解密中每轮的密钥分别由初始密钥扩展得到。</p>
<h3 id="1-2-状态-State"><a href="#1-2-状态-State" class="headerlink" title="1.2 状态(State) "></a><font size=3>1.2 状态(State) </font></h3><p>AES算法的运算都是在一个称为状态的二维字节数组上进行。一个状态由四行组成， 每一行包括Nb个字节，Nb等于分组长度除以32。用s表示一个状态矩阵，每一个字节的 位置由行号r (范围是 $0 \leq 0 \lt 4$ )和列号c (范围是$0 \leq c \lt Nb$ )唯一确定，记为$s_{r,c}$或$s[r,c]$。 在AES-FIPS197标准中Nb&#x3D;4，即$0 \leq c \lt 4$。 </p>
<p>在加密和解密的初始阶段将输入字节数组$in_{0},in_{1},…,in_{15}$复制到如图所示的状态矩阵中。加密或解密的运算都在该状态矩阵上进行，最后的结果将被复制到输出 字节数组$out_{0},out_{1},…,out_{15}$​。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240812074842387.png" alt="image-20240812074842387" style="zoom:50%;" />

<p>在加密和解密的初始阶段，输入数组in按照下述规则复制到状态矩阵中：<br>$$<br>s[r,c]&#x3D;in[r+4c] \space\space\space\space for \space 0 \leq r \lt 4 \text{ 且 } 0 \leq c \lt Nb<br>$$<br>在加密和解密的结束阶段，状态矩阵将按照下述规则被复制到输出数组out中：<br>$$<br>out[r+4c]&#x3D;s[r,c] \space\space\space\space for \space 0 \leq r \lt 4 \text{ 且 } 0 \leq c \lt Nb<br>$$</p>
<h3 id="1-3-加解密函数"><a href="#1-3-加解密函数" class="headerlink" title="1.3 加解密函数"></a><font size=3>1.3 加解密函数</font></h3><p>设AES加密函数为E，则<br>$$<br>C &#x3D; E(K, P)<br>$$</p>
<p>其中P为明文，K为密钥，C为密文。也就是说，把明文P和密钥K作为加密函数的参数输入，则加密函数E会输出密文C。</p>
<p>设AES解密函数为D，则<br>$$<br>P &#x3D; D(K, C)<br>$$<br>其中C为密文，K为密钥，P为明文。也就是说，把密文C和密钥K作为解密函数的参数输入，则解密函数会输出明文P。</p>
<h2 id="2-AES算法流程"><a href="#2-AES算法流程" class="headerlink" title="2. AES算法流程"></a><font size=3>2. AES算法流程</font></h2><p>AES 128的整体结构如下图所示，其中的W[0:3]是指W[0]、W[1]、W[2]和W[3]串联组成的128位密钥。上面说到，AES的加密公式为<br>$$<br>C &#x3D; E(K,P)<br>$$<br>在加密函数E中，会执行一个轮函数，并且执行10次这个轮函数，加密的第1轮到第9轮的轮函数一样，只有第10次有所不同。前9轮中，每轮包括4个操作：字节代换、行位移、列混合和轮密钥加。也就是说，一个明文分组会被加密10轮。</p>
<p>AES的核心就是实现一轮中的所有操作。由于每一步操作都是可逆的，按照相反的顺序进行解密即可恢复明文。最后一轮迭代不执行列混合。另外，在第一轮迭代之前，先将明文和原始密钥进行一次异或加密操作。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240823075327904.png" alt="image-20240823075327904" style="zoom: 33%;" />

<p>加解密中每轮的密钥分别由初始密钥扩展得到。算法中16个字节的明文、密文和轮密钥都以一个4x4的矩阵表示。</p>
<p>AES的处理单位是字节，128位的输入明文分组P和输入密钥K都被分成16个字节，分别记为P &#x3D; P0 P1 … P15 和 K &#x3D; K0 K1 … K15。如，明文分组为P &#x3D; abcdefghijklmnop，其中的字符a对应P0，p对应P15。一般地，明文分组用字节为单位的正方形矩阵描述，称为状态矩阵。在算法的每一轮中，状态矩阵的内容不断发生变化，最后的结果作为密文输出。该矩阵中字节的排列顺序为从上到下、从左至右依次排列，如下图所示： </p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240817062647468.png" alt="image-20240817062647468" style="zoom:50%;" />

<p>假设明文分组P为”abcdefghijklmnop”，则对应上面生成的状态矩阵图如下(此图并未验证数据实际是否是这样，作为参考)：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240817063141047.png" alt="image-20240817063141047" style="zoom:50%;" />

<p>类似地，128位密钥也是用字节为单位的矩阵表示，矩阵的每一列被称为1个32位比特字。通过密钥编排函数该密钥矩阵被扩展成一个44个字组成的序列W[0],W[1], … ,W[43],该序列的前4个元素W[0],W[1],W[2],W[3]是原始密钥，用于加密运算中的初始密钥加，后面40个字分为10组，每组4个字（128比特）分别用于10轮加密运算中的轮密钥加，如下图所示： </p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240817063951940.png" alt="image-20240817063951940" style="zoom:50%;" />

<p>上图中，设K &#x3D; “abcdefghijklmnop”，则K0 &#x3D; a, K15 &#x3D; p, W[0] &#x3D; [K0 K1 K2 K3] &#x3D; “abcd”。</p>
<h2 id="3-加密步骤分析"><a href="#3-加密步骤分析" class="headerlink" title="3. 加密步骤分析"></a><font size=3>3. 加密步骤分析</font></h2><p>伪代码如下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240822074907843.png" alt="image-20240822074907843" style="zoom:33%;" />

<h3 id="3-1-字节替代-SubBytes-变换"><a href="#3-1-字节替代-SubBytes-变换" class="headerlink" title="3.1 字节替代(SubBytes( ))变换 "></a><font size=3>3.1 字节替代(SubBytes( ))变换 </font></h3><p>字节替代(SubBytes（）)变换是一个非线性的字节替代，它独立地将状态中的每个字节利用替代表(S盒)进行运算。SubBytes（）变换在状态上的作用效果如图6：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240820073919337.png" alt="image-20240820073919337" style="zoom:40%;" />

<p>该S盒(图7)是可逆的，由两个变换复合而成： </p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240816075348961.png" alt="image-20240816075348961" style="zoom: 40%;" />

<p>图7为以16进制表示的SubBytes（）变换对应的S盒。例如，如果$S_{1,1} &#x3D;{53}$，则替代后的值将由图7中行标为5列标为3的交集决定。即$S’_{1,1} &#x3D; {ed}$。</p>
<p>根据例子可知状态矩阵中的元素按照下面的方式映射为一个新的字节：把该字节的高4位作为行值，低4位作为列值，取出S盒或者逆S盒中对应的行的元素作为输出。例如，加密时，输出的字节S1为0xA9,则查S盒的第0x0A行和0x09列，得到值0xD3，然后替换S1原有的0xA9为0xD3。状态矩阵经字节代换后的图如下： </p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240820075017532.png" alt="image-20240820075017532" style="zoom:50%;" />

<h3 id="3-2-行移位-ShiftRows-变换"><a href="#3-2-行移位-ShiftRows-变换" class="headerlink" title="3.2 行移位(ShiftRows( ))变换"></a><font size=3>3.2 行移位(ShiftRows( ))变换</font></h3><p>行移位是一个简单的左循环移位操作。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240820225731801.png" alt="image-20240820225731801" style="zoom:38%;" />

<p>当密钥长度为128比特时，状态矩阵的第0行左移0字节，第1行左移1字节，第2行左移2字节，第3行左移3字节，如下图所示：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240820075855856.png" alt="image-20240820075855856" style="zoom:50%;" />

<h3 id="3-3-列混合-MixColumns-变换"><a href="#3-3-列混合-MixColumns-变换" class="headerlink" title="3.3 列混合(MixColumns( ))变换"></a><font size=3>3.3 列混合(MixColumns( ))变换</font></h3><img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240820230459937.png" alt="image-20240820230459937" style="zoom:43%;" />

<p>列混合变换是通过矩阵相乘来实现的，经行移位后的状态矩阵与固定的矩阵相乘，得到混合后的状态矩阵，如下图的公式所示：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240820231532597.png" alt="image-20240820231532597" style="zoom:40%;" />

<p>完整的公式为：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/e2c06e75355a5646c48e9e34d6b6ae8c.png" alt="img" style="zoom: 80%;" />

<p>其中，矩阵元素的乘法和加法都是定义在基于GF(2^8)上的二元运算,并不是通常意义上的乘法和加法。这里涉及到一些信息安全上的数学知识，其实这种二元运算的加法等价于两个字节的异或，乘法则复杂一点。对于一个8位的二进制数来说，使用域上的乘法乘以(00000010)等价于左移1位(低位补0)后，再根据情况同(00011011)进行异或运算，设S1 &#x3D; (a7 a6 a5 a4 a3 a2 a1 a0)，刚0x02 * S1如下图所示：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/3d2821753c987009467ee4bc32bd5d47.png" alt="col3" style="zoom:80%;" />

<p>也就是说，如果a7为1，则进行异或运算，否则不进行。类似地，乘以(00000100)可以拆分成两次乘以(00000010)的运算：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/59a9189060c3282ac955e94998353c9d.png" alt="col4" style="zoom:80%;" />

<p>乘以(0000 0011)可以拆分成先分别乘以(0000 0001)和(0000 0010)，再将两个乘积异或：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/3cd9fdef1e1047d154a8c11bcfb898fa.png" alt="在这里插入图片描述" style="zoom: 50%;" />

<p>因此，我们只需要实现乘以2的函数，其他数值的乘法都可以通过组合来实现。 所以列混合运算可以写成如下公式，以其中一列为例：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240821070949198.png" alt="image-20240821070949198" style="zoom: 43%;" />



<p>举个例子：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240821071859030.png" alt="image-20240821071859030" style="zoom:50%;" />

<h3 id="3-4-轮密钥加-AddRoundKey-变换"><a href="#3-4-轮密钥加-AddRoundKey-变换" class="headerlink" title="3.4 轮密钥加(AddRoundKey( ))变换 "></a><font size=3>3.4 轮密钥加(AddRoundKey( ))变换 </font></h3><p>轮密钥加是将128位轮密钥Ki同状态矩阵中的数据进行逐位异或操作。如下图所示。其中，密钥Ki中每个字W[4i],W[4i+1],W[4i+2],W[4i+3]为32位比特字，包含4个字节。轮密钥加过程可以看成是字逐位异或的结果，也可以看成字节级别或者位级别的操作。也就是说，可以看成S0 S1 S2 S3 组成的32位字与W[4i]的异或运算。 </p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240821072925306.png" alt="image-20240821072925306" style="zoom:40%;" />

<p>其实就是下图这个样子：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240821072902597.png" alt="image-20240821072902597" style="zoom:50%;" />

<h3 id="3-5-密钥扩展"><a href="#3-5-密钥扩展" class="headerlink" title="3.5 密钥扩展"></a><font size=3>3.5 密钥扩展</font></h3><p>AES首先将初始密钥输入到一个4*4的状态矩阵中，如下图所示，这个4*4矩阵的每一列的4个字节组成一个字，矩阵4列的4个字依次命名为W[0]、W[1]、W[2]和W[3]，它们构成一个以字为单位的数组W。例如，设密钥K为”abcdefghijklmnop”,则K0 &#x3D; ‘a’,K1 &#x3D; ‘b’, K2 &#x3D; ‘c’,K3 &#x3D; ‘d’,W[0] &#x3D; “abcd”：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240821073739426.png" alt="image-20240821073739426" style="zoom:50%;" />

<p>然后，对W数组扩充40个新列，构成总共44列的扩展密钥数组。新列以如下的递归方式产生： </p>
<p>（1）如果i不是4的倍数，那么第i列由$W[i]&#x3D;W[i-4] \bigoplus W[i-1]$确定</p>
<p>（2）如果i是4的倍数，那么第i列由等式$W[i]&#x3D;W[i-4] \bigoplus T(W[i-1]) $确定</p>
<p>其中，T是一个有点复杂的函数。 函数T由3部分组成：字循环、字节代换和轮常量异或，这3部分的作用分别如下。 </p>
<p>a.字循环：将1个字中的4个字节循环左移1个字节。即将输入字[b0, b1, b2, b3]变换成[b1,b2,b3,b0]。 </p>
<p>b.字节代换：对字循环的结果使用S盒进行字节代换。 </p>
<p>c.轮常量异或：将前两步的结果同轮常量Rcon[j]进行异或，其中j表示轮数。 </p>
<p>轮常量Rcon[j]是一个字，其值见下表。</p>
<table>
<thead>
<tr>
<th align="center">j</th>
<th align="center">1</th>
<th align="center">2</th>
<th align="center">3</th>
<th align="center">4</th>
<th align="center">5</th>
</tr>
</thead>
<tbody><tr>
<td align="center">Rcon[j]</td>
<td align="center">01 00 00 00</td>
<td align="center">02 00 00 00</td>
<td align="center">04 00 00 00</td>
<td align="center">08 00 00 00</td>
<td align="center">10 00 00 00</td>
</tr>
<tr>
<td align="center"><strong>j</strong></td>
<td align="center"><strong>6</strong></td>
<td align="center"><strong>7</strong></td>
<td align="center"><strong>8</strong></td>
<td align="center"><strong>9</strong></td>
<td align="center"><strong>10</strong></td>
</tr>
<tr>
<td align="center">Rcon[j]</td>
<td align="center">20 00 00 00</td>
<td align="center">40 00 00 00</td>
<td align="center">80 00 00 00</td>
<td align="center">1B 00 00 00</td>
<td align="center">36 00 00 00</td>
</tr>
</tbody></table>
<p>举个例子，设初始的128位密钥为：<code>3C A1 0B 21 57 F0 19 16 90 2E 13 80 AC C1 07 BD</code>，那么4个初始值为：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">W[0] = 3C A1 0B 21 </span><br><span class="line">W[1] = 57 F0 19 16 </span><br><span class="line">W[2] = 90 2E 13 80 </span><br><span class="line">W[3] = AC C1 07 BD </span><br></pre></td></tr></table></figure>

<p>下面求扩展的第1轮的子密钥($W[4],W[5],W[6],W[7]$)。由于4是4的倍数，所以： $$W[4]&#x3D;W[0] \bigoplus T(W[3]) $$。$T(W[3])$的计算步骤如下： </p>
<p>（1）循环地将W[3]的元素移位：AC C1 07 BD变成C1 07 BD AC; </p>
<p>（2）将 C1 07 BD AC 作为S盒的输入，输出为78 C5 7A 91; </p>
<p>（3）将78 C5 7A 91与第一轮轮常量Rcon[1]进行异或运算，将得到79 C5 7A 91，因此，T(W[3])&#x3D;79 C5 7A 91，故<br>$$<br>W[4] &#x3D; \text{3C A1 0B 21} \bigoplus \text{79 C5 7A 91} &#x3D; \text{45 64 71 B0}<br>$$<br>其余的3个子密钥段的计算如下：<br>$$<br>\begin{flalign}<br>&amp;W[5] &#x3D; W[1] \bigoplus W[4] &#x3D; \text{57 F0 19 16} \bigoplus \text{45 64 71 B0} &#x3D; \text{12 94 68 A6 } \newline<br>&amp;W[6] &#x3D; W[2] \bigoplus W[5] &#x3D;\text{90 2E 13 80} \bigoplus \text{12 94 68 A6} &#x3D; \text{82 BA 7B 26 } \newline<br>&amp;W[7] &#x3D; W[3] \bigoplus W[6] &#x3D; \text{AC C1 07 BD} \bigoplus \text{82 BA 7B 26} &#x3D; \text{2E 7B 7C 9B } \newline<br>\end{flalign}<br>$$<br>所以，第一轮的密钥为<code>45 64 71 B0 12 94 68 A6 82 BA 7B 26 2E 7B 7C 9B</code>。</p>
<blockquote>
<p>密钥扩展伪代码：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240822075011547.png" alt="image-20240822075011547" style="zoom: 50%;" />
</blockquote>
<h2 id="4-解密步骤分析"><a href="#4-解密步骤分析" class="headerlink" title="4. 解密步骤分析"></a><font size=3>4. 解密步骤分析</font></h2><p>将加密变换逆转，然后以逆序执行即可直接得到解密 算法。解密算法伪代码：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240822075049267.png" alt="image-20240822075049267" style="zoom: 33%;" />

<h3 id="4-1-逆行移位-InvShiftRows-变换"><a href="#4-1-逆行移位-InvShiftRows-变换" class="headerlink" title="4.1 逆行移位(InvShiftRows( ))变换 "></a><font size=3>4.1 逆行移位(InvShiftRows( ))变换 </font></h3><img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240822074321355.png" alt="image-20240822074321355" style="zoom:40%;" />

<h3 id="4-2-逆字节替代-InvSubBytes-变换"><a href="#4-2-逆字节替代-InvSubBytes-变换" class="headerlink" title="4.2 逆字节替代(InvSubBytes( ))变换 "></a><font size=3>4.2 逆字节替代(InvSubBytes( ))变换 </font></h3><p>逆字节替代(InvSubBytes（）)变换是字节替代(SubBytes（）)变换的逆变换，在状态的 每个字节上应用S盒的逆。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240822074410571.png" alt="image-20240822074410571" style="zoom:40%;" />

<h3 id="4-3-逆列混合-InvMixColumns-变换"><a href="#4-3-逆列混合-InvMixColumns-变换" class="headerlink" title="4.3 逆列混合(InvMixColumns( ))变换"></a><font size=3>4.3 逆列混合(InvMixColumns( ))变换</font></h3><p>逆列混合(InvMixColumns（）)变换是列混合(MixColumns（）)变换的逆变换。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240822074457918.png" alt="image-20240822074457918" style="zoom:40%;" />

<p>经过该乘法计算后，一列中的4个字节将由下述结果取代：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240822074526335.png" alt="image-20240822074526335" style="zoom:40%;" />

<h3 id="4-4-轮密钥加-AddRoundKey-变换的逆变换"><a href="#4-4-轮密钥加-AddRoundKey-变换的逆变换" class="headerlink" title="4.4 轮密钥加(AddRoundKey())变换的逆变换 "></a><font size=3>4.4 轮密钥加(AddRoundKey())变换的逆变换 </font></h3><p>轮密钥加( AddRoundKey())变换，其逆变换就是它本身，因为其中 只应用了异或(XOR)运算。 </p>
<h3 id="4-5-等价的解密变换"><a href="#4-5-等价的解密变换" class="headerlink" title="4.5 等价的解密变换"></a><font size=3>4.5 等价的解密变换</font></h3><p>2.AES算法流程一节中的图，所描述的直接得到的解密算法中，其各个变换的操作顺序与加密算法 不同，伪代码对比如下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240822075251313.png" alt="image-20240822075251313" style="zoom:50%;" />



<p>但是加密和解密算法中的密钥编排形式相同。然而，AES算法的若干性质允许构造 一个等价的解密算法，解密时各个变换的操作顺序与加密(由逆变换取代原来的变换)相同。 这是通过改变密钥编排完成的。</p>
<p>允许该等价解密变换的二个关键性质如下：  </p>
<p>（1）字节替代(SubBytes（）)变换和行移位(ShiftRows（）)变换的顺序不影响结果。即， 先进行字节替代(SubBytes（）)变换紧接着进行行移位(ShiftRows（）)变换等价于 先进行行移位(ShiftRows（）)变换紧接着再进行字节替代(SubBytes（）)变换。对于逆变换InvSubBytes（）和InvShiftRows（），该性质也成立。  </p>
<p>（2）列混合运算－MixColumns（）和InvMixColumns（）－是关于列输入的线性变换， 即意味着  InvMixColumns（state XOR Round Key）＝  InvMixColumns（state） XOR InvMixColumns（Round Key） </p>
<p>这些性质使得InvSubBytes（）变换和InvShiftRows（）变换可以交换顺序。AddRoundKey （）变换和InvMixColumns（）变换的顺序也可以交换，只要将解密中密钥编排得到的密 钥列（字）应用InvMixColumns（）变换进行修改即可。</p>
<p>等价的解密算法如图12所示，定义为将InvSubBytes（）变换和InvShiftRows（）变 换的顺序反转过来，同时当利用InvMixColumns（）变换先修改了1到Nr-1轮的解密密钥 编排结果后，将“轮循环”中使用的AddRoundKey（）变换和InvMixColumns（）变换的 顺序反转。解密密钥编排结果的第一和最后Nb字将不使用该方式进行修改。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240822075634528.png" alt="image-20240822075634528" style="zoom:50%;" />

<p>基本流程图如下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240824064237513.png" alt="image-20240824064237513" style="zoom:50%;" />

<h1 id="三、加密模式"><a href="#三、加密模式" class="headerlink" title="三、加密模式"></a><font size=3>三、加密模式</font></h1><p>对于对称加密一般分为流加密(如OFB、CFB等)和块加密(如ECB、CBC等)。一般的加密通常都是块加密，对于块加密(或称分组加密)，如果要加密超过块大小的数据，就需要涉及填充和链加密模式。</p>
<blockquote>
<p>块加密和流加密的基本概念：</p>
<ul>
<li>块加密：或者叫分组加密， <strong>块</strong> 为单位进行一次加密，将明文按一定的位长分组成块，明文块加密后得到密文组。解密雷同，密文组解密还原成明文组。</li>
<li>流加密：或者交序列加密，以 <strong>位</strong> 为单位进行一次加密，利用少量的密钥通过某种复杂的密码算法进行运算产生大量的伪随机位流，用于对明文位流的加密。</li>
</ul>
</blockquote>
<h2 id="1-AES填充方式"><a href="#1-AES填充方式" class="headerlink" title="1. AES填充方式"></a><font size=3>1. AES填充方式</font></h2><img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/image-20240824070820815.png" alt="image-20240824070820815" style="zoom:50%;" />

<p>以aes128为例，这里的每个明文块都是16字节，一共是128位。这里有一个问题，就是，明文数据最后不够16字节怎么办？比如这段数据有43个字节，我们可以分成两个16字节的明文块再加一个11字节的明文块，这最后一个少了5个字节。这时候就需要对最后的这11字节明文块进行处理，常见的填充方案有如下几种：</p>
<ul>
<li>PKCS7（Padding Cryptography System 7）填充：在明文末尾添加填充字节，填充字节的值等于需要填充的字节数。</li>
</ul>
<p>填充字符串由一个字节序列组成，每个字节填充该字节序列的长度。假定块长度为 8，数据长度为 9，则填充用八位字节数等于 7，数据如下：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">FF FF FF FF FF FF FF FF FF</span><br><span class="line">这样可以分为两块：</span><br><span class="line">块0 FF FF FF FF FF FF FF FF    </span><br><span class="line">块1 FF</span><br></pre></td></tr></table></figure>

<p>PKCS7 填充后如下所示：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">块0 FF FF FF FF FF FF FF FF    </span><br><span class="line">块1 FF 07 07 07 07 07 07 07</span><br></pre></td></tr></table></figure>

<ul>
<li><p>PKCS5（Padding Cryptography System 5）填充：与PKCS7填充类似，只是该种填充方式用于8字节分组的加密算法。</p>
</li>
<li><p>NoPadding填充：不进行任何填充，要求明文长度必须是分组长度的整数倍。</p>
</li>
</ul>
<p>也有一些其他的填充方式，比如全填0之类的，但一般，自己在使用的时候，没什么特殊要求的时候，最后不足16字节的不加密就可以了。</p>
<h2 id="2-加密模式"><a href="#2-加密模式" class="headerlink" title="2. 加密模式"></a><font size=3>2. 加密模式</font></h2><p>aes加密是分组加密，所以不仅涉及到填充方式，还会涉及到加密的模式，一般有五种：</p>
<ul>
<li><p>电码本模式（Electronic Codebook Book (ECB)）</p>
</li>
<li><p>密码分组链接模式（Cipher Block Chaining (CBC)）</p>
</li>
<li><p>计算器模式（Counter (CTR)）</p>
</li>
<li><p>密码反馈模式（Cipher FeedBack (CFB)）</p>
</li>
<li><p>输出反馈模式（Output FeedBack (OFB)）</p>
</li>
</ul>
<h3 id="2-1-ECB-模式"><a href="#2-1-ECB-模式" class="headerlink" title="2.1 ECB 模式"></a><font size=3>2.1 ECB 模式</font></h3><blockquote>
<p><a target="_blank" rel="noopener" href="https://xilinx.github.io/Vitis_Libraries/security/2020.1/guide_L1/internals/ecb.html#ecb-mode">ecb-mode</a></p>
<p>The Electronic Codebook (ECB) mode is a typical block cipher mode of operation using block cipher algorithm. In this version, we provide Data Encryption Standard (DES) and Advanced Encryption Standard (AES) processing ability, the cipherkey length for DES should be 64 bits, and 128&#x2F;192&#x2F;256 bits for AES. Another limitation is that our working mode works on units of a fixed size (64 or 128 bits for 1 block), but text in the real world has a variety of lengths. So, the last block of the text provided to this primitive must be padded to 128 bits before encryption or decryption.</p>
</blockquote>
<p>ECB模式是最早采用和最简单的模式，它将加密的数据分成若干组，每组的大小跟加密密钥长度相同，然后每组都用相同的密钥进行加密。</p>
<table>
<thead>
<tr>
<th></th>
<th>plaintext</th>
<th>ciphertext</th>
<th>cipherkey</th>
<th>IV</th>
</tr>
</thead>
<tbody><tr>
<td>ECB-DES</td>
<td>64</td>
<td>64</td>
<td>64</td>
<td>64</td>
</tr>
<tr>
<td>ECB-AES128</td>
<td>128</td>
<td>128</td>
<td>128</td>
<td>128</td>
</tr>
<tr>
<td>ECB-AES192</td>
<td>128</td>
<td>128</td>
<td>192</td>
<td>128</td>
</tr>
<tr>
<td>ECB-AES256</td>
<td>128</td>
<td>128</td>
<td>256</td>
<td>128</td>
</tr>
</tbody></table>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/ECB_working_mode.png" alt="algorithm flow chart of ECB" style="zoom:50%;" />

<p><strong>优点</strong>：</p>
<ul>
<li>简单，易实现，可并行缺点：</li>
</ul>
<p><strong>缺点</strong>：</p>
<ul>
<li>分组进行加密，加密方式一致，那么可根据密文情况观察到明文情况，有被破解的风险，不安全。</li>
<li>加密消息块相互独立成为被攻击的弱点，不能提供严格的数据保密性，可以对明文进行主动攻击。</li>
</ul>
<h3 id="2-2-CBC-模式"><a href="#2-2-CBC-模式" class="headerlink" title="2.2 CBC 模式"></a><font size=3>2.2 CBC 模式</font></h3><blockquote>
<p><a target="_blank" rel="noopener" href="https://xilinx.github.io/Vitis_Libraries/security/2020.1/guide_L1/internals/cbc.html#cbc-mode">cbc-mode</a></p>
<p>The Cipher Block Chaining (CBC) mode is a typical block cipher mode of operation using block cipher algorithm. In this version, we provide Data Encryption Standard (DES) and Advanced Encryption Standard (AES) processing ability, the cipherkey length for DES should be 64 bits, and 128&#x2F;192&#x2F;256 bits for AES. Another limitation is that our working mode works on units of a fixed size (64 or 128 bits for 1 block), but text in the real world has a variety of lengths. So, the last block of the text provided to this primitive must be padded to 128 bits before encryption or decryption.</p>
</blockquote>
<p>CBC模式由IBM发明与1976年，在CBC模式中，每个平文块先与前一个密文块进行异或后，再进行加密。在这种方法中，每个密文块都依赖于它前面的所有密文块。同时，为了保证每条消息的唯一性，在第一个块中需要使用初始化向量。</p>
<table>
<thead>
<tr>
<th></th>
<th>plaintext</th>
<th>ciphertext</th>
<th>cipherkey</th>
<th>IV</th>
</tr>
</thead>
<tbody><tr>
<td>CBC-DES</td>
<td>64</td>
<td>64</td>
<td>64</td>
<td>64</td>
</tr>
<tr>
<td>CBC-AES128</td>
<td>128</td>
<td>128</td>
<td>128</td>
<td>128</td>
</tr>
<tr>
<td>CBC-AES192</td>
<td>128</td>
<td>128</td>
<td>192</td>
<td>128</td>
</tr>
<tr>
<td>CBC-AES256</td>
<td>128</td>
<td>128</td>
<td>256</td>
<td>128</td>
</tr>
</tbody></table>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/CBC_working_mode.png" alt="algorithm flow chart of CBC" style="zoom:50%;" />

<p>可以看到，这种方法的每个密文块都依赖于它前面的明文块，使加密的各段数据之间有了联系，保证了每条消息的唯一性。第一个块中需要使用始化向量IV。加密的时候，第一块后的每一块 需要先与前一个密文异或再加密 $Ci &#x3D; Ek (P \bigoplus Ci-1), C0 &#x3D; IV$。解密的时候，一个密文会影响到该明文与后一个明文，不会对其他明文产生影响 $Pi &#x3D; Dk (Ci) \bigoplus Ci-1, C0 &#x3D; IV$。</p>
<p><strong>优点：</strong></p>
<ul>
<li>无法直接从密文中看出明文信息块的规律，所以安全性比较好</li>
<li>因密文块依赖于所有的信息块，加密时，若明文块有一个消息改变则影响所有密文块</li>
<li>加密解密过程都需要 初始化向量（而且要相同）</li>
</ul>
<p><strong>缺点：</strong></p>
<ul>
<li><p>因为具备依赖性，加密过程是串行的，无法被并行化，但是解密可以并行化，因为一个密文会影响到该明文与后一个明文，不会对其他明文产生影响</p>
</li>
<li><p>数据必须是块大小的整数倍，不够需要填充</p>
</li>
</ul>
<h3 id="2-3-CTR-模式"><a href="#2-3-CTR-模式" class="headerlink" title="2.3 CTR 模式"></a><font size=3>2.3 CTR 模式</font></h3><blockquote>
<p><a target="_blank" rel="noopener" href="https://xilinx.github.io/Vitis_Libraries/security/2020.1/guide_L1/internals/ctr.html#ctr-mode">ctr-mode</a></p>
<p>The Counter (CTR) mode is a typical block cipher mode of operation using block cipher algorithm. In this version, we provide Advanced Encryption Standard (AES) processing ability, the cipherkey length for AES should be 128&#x2F;192&#x2F;256 bits. Another limitation is that our working mode works on units of a fixed size (128 bits for 1 block), but text in the real world has a variety of lengths. So, the last block of the text provided to this primitive must be padded to 128 bits before encryption or decryption.</p>
</blockquote>
<p>计算器模式不常见，在CTR模式中， 有一个自增的算子，这个算子用密钥加密之后的输出和明文异或的结果得到密文，相当于一次一密。这种加密方式简单快速，安全可靠，而且可以并行加密，但是在计算器不能维持很长的情况下，密钥只能使用一次。</p>
<table>
<thead>
<tr>
<th></th>
<th>plaintext</th>
<th>ciphertext</th>
<th>cipherkey</th>
<th>IV</th>
</tr>
</thead>
<tbody><tr>
<td>CTR-AES128</td>
<td>128</td>
<td>128</td>
<td>128</td>
<td>128</td>
</tr>
<tr>
<td>CTR-AES192</td>
<td>128</td>
<td>128</td>
<td>192</td>
<td>128</td>
</tr>
<tr>
<td>CTR-AES256</td>
<td>128</td>
<td>128</td>
<td>256</td>
<td>128</td>
</tr>
</tbody></table>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/CTR_working_mode.png" alt="algorithm flow chart of CTR" style="zoom:50%;" />

<p><strong>优点：</strong></p>
<ul>
<li>允许并行计算、允许同时处理多块明文 &#x2F; 密文</li>
<li>可随机访问，算法和加密盒的输出不依靠明文和密文的输入，因此如果有足够的保证安全的存储器，加密算法将仅仅是一系列异或运算，这将极大地提高吞吐量。</li>
<li>与CFB一样，无需填充</li>
</ul>
<p><strong>缺点：</strong></p>
<h3 id="2-4-CFB-模式"><a href="#2-4-CFB-模式" class="headerlink" title="2.4 CFB 模式"></a><font size=3>2.4 CFB 模式</font></h3><blockquote>
<p><a target="_blank" rel="noopener" href="https://xilinx.github.io/Vitis_Libraries/security/2020.1/guide_L1/internals/cfb.html#cfb-mode">cfb-mode</a></p>
<p>The Cipher Feedback (CFB) mode is a typical block cipher mode of operation using block cipher algorithm. In this version, we provide Data Encryption Standard (DES) and Advanced Encryption Standard (AES) processing ability, the cipherkey length for DES should be 64 bits, and 128&#x2F;192&#x2F;256 bits for AES. Another limitation is that our working mode works on units of a fixed size (64 or 128 bits for 1 block), but text in the real world has a variety of lengths. So, the last block of the text provided to this primitive must be padded to 128 bits before encryption or decryption. Although, CFB1 and CFB8 modes share the same interface with CFB128 mode, the plaintext and ciphertext is processed bit-by-bit or byte-by-byte not block-by-block for CFB1 and CFB8 modes respectively.</p>
</blockquote>
<p><strong>前一个密文</strong>使用<strong>秘钥Key</strong>再加密后，<strong>与明文异或，得到密文</strong>。第一个密文需要初始向量IV加密得到。解密也同样使用加密器进行解密。</p>
<table>
<thead>
<tr>
<th></th>
<th>plaintext</th>
<th>ciphertext</th>
<th>cipherkey</th>
<th>IV</th>
</tr>
</thead>
<tbody><tr>
<td>CFB1-DES</td>
<td>64</td>
<td>64</td>
<td>64</td>
<td>64</td>
</tr>
<tr>
<td>CFB1-AES128</td>
<td>128</td>
<td>128</td>
<td>128</td>
<td>128</td>
</tr>
<tr>
<td>CFB1-AES192</td>
<td>128</td>
<td>128</td>
<td>192</td>
<td>128</td>
</tr>
<tr>
<td>CFB1-AES256</td>
<td>128</td>
<td>128</td>
<td>256</td>
<td>128</td>
</tr>
<tr>
<td>CFB8-DES</td>
<td>64</td>
<td>64</td>
<td>64</td>
<td>64</td>
</tr>
<tr>
<td>CFB8-AES128</td>
<td>128</td>
<td>128</td>
<td>128</td>
<td>128</td>
</tr>
<tr>
<td>CFB8-AES192</td>
<td>128</td>
<td>128</td>
<td>192</td>
<td>128</td>
</tr>
<tr>
<td>CFB8-AES256</td>
<td>128</td>
<td>128</td>
<td>256</td>
<td>128</td>
</tr>
<tr>
<td>CFB128-DES</td>
<td>64</td>
<td>64</td>
<td>64</td>
<td>64</td>
</tr>
<tr>
<td>CFB128-AES128</td>
<td>128</td>
<td>128</td>
<td>128</td>
<td>128</td>
</tr>
<tr>
<td>CFB128-AES192</td>
<td>128</td>
<td>128</td>
<td>192</td>
<td>128</td>
</tr>
<tr>
<td>CFB128-AES256</td>
<td>128</td>
<td>128</td>
<td>256</td>
<td>128</td>
</tr>
</tbody></table>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/CFB_working_mode.png" alt="algorithm flow chart of CFB" style="zoom:50%;" />



<p><strong>说明：</strong></p>
<ul>
<li><p>第一个块中都需要使用初始化向量IV</p>
</li>
<li><p>加密：通过密钥key加密后与明文进行异或得到密文，后面所有的加密都依赖于前一个加密后的输出，CFB是依赖前一个密文。</p>
</li>
<li><p>解密：通过密钥加密后，与密文进行异或得到明文，当前的 加密后的输出 会影响当前的明文与下一个明文，不会影响所有明文的生成，CFB是 密文会影响，而不是加密后的输出。</p>
</li>
</ul>
<p><strong>优点：</strong></p>
<ul>
<li>隐藏了明文模式</li>
<li>加密前后的数据位数是相同的</li>
<li>可以及时加密传送小于分组的数据</li>
</ul>
<p><strong>缺点：</strong></p>
<ul>
<li>与CBC类似，加密不利于并行计算，解密可以并行计算</li>
<li>加密时一个明文单元损坏影响多个单元</li>
<li>加密解密需要唯一的一个与块的大小相同的移位寄存器，并用初始化向量IV将寄存器初始化</li>
</ul>
<h3 id="2-5-OFB模式"><a href="#2-5-OFB模式" class="headerlink" title="2.5 OFB模式"></a><font size=3>2.5 OFB模式</font></h3><blockquote>
<p><a target="_blank" rel="noopener" href="https://xilinx.github.io/Vitis_Libraries/security/2020.1/guide_L1/internals/ofb.html#ofb-mode">ofb-mode</a></p>
<p>The Output Feedback (OFB) mode is a typical block cipher mode of operation using block cipher algorithm. In this version, we provide Data Encryption Standard (DES) and Advanced Encryption Standard (AES) processing ability, the cipherkey length for DES should be 64 bits, and 128&#x2F;192&#x2F;256 bits for AES. Another limitation is that our working mode works on units of a fixed size (64 or 128 bits for 1 block), but text in the real world has a variety of lengths. So, the last block of the text provided to this primitive must be padded to 128 bits before encryption or decryption.</p>
</blockquote>
<p>首先用 <strong>块加密器</strong> 生成 <strong>密钥流（Keystream）</strong>，然后再将<strong>密钥流与明文流异或得到密文流</strong>；解密是先用<strong>块加密器生成密钥流</strong>，再将密钥流与密文流异或得到明文 （与CFB类似）</p>
<table>
<thead>
<tr>
<th></th>
<th>plaintext</th>
<th>ciphertext</th>
<th>cipherkey</th>
<th>IV</th>
</tr>
</thead>
<tbody><tr>
<td>OFB-DES</td>
<td>64</td>
<td>64</td>
<td>64</td>
<td>64</td>
</tr>
<tr>
<td>OFB-AES128</td>
<td>128</td>
<td>128</td>
<td>128</td>
<td>128</td>
</tr>
<tr>
<td>OFB-AES192</td>
<td>128</td>
<td>128</td>
<td>192</td>
<td>128</td>
</tr>
<tr>
<td>OFB-AES256</td>
<td>128</td>
<td>128</td>
<td>256</td>
<td>128</td>
</tr>
</tbody></table>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/04%E9%9F%B3%E8%A7%86%E9%A2%91/LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/LV04-02-AES%E7%AE%97%E6%B3%95-01-AES%E7%AE%97%E6%B3%95%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86/img/OFB_working_mode.png" alt="algorithm flow chart of OFB" style="zoom:50%;" />

<blockquote>
<p>参考资料：</p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_28205153/article/details/55798628">AES加密算法原理的详细介绍与实现-CSDN博客</a></p>
<p><a target="_blank" rel="noopener" href="https://www.cnblogs.com/vegetableDD/p/11866251.html">AES加密算法原理（加密过程） - Shawn_Michaels - 博客园 (cnblogs.com)</a></p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/gulang03/article/details/81175854">AES 加密算法的原理详解_aes原理-CSDN博客</a></p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/weixin_42233867/article/details/130736725">深入探究AES加密算法：加密原理、模式和填充方式详解_aes填充模式-CSDN博客</a></p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/u010003835/article/details/81035768">密码学_AES-加密算法\ 详解_aes cfb算法-CSDN博客</a></p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/charleslei/article/details/48710293">高级加密标准AES的工作模式（ECB、CBC、CFB、OFB）_aes cfb-CSDN博客</a></p>
<p><a target="_blank" rel="noopener" href="https://www.wikiwand.com/zh-cn/%E9%AB%98%E7%BA%A7%E5%8A%A0%E5%AF%86%E6%A0%87%E5%87%86">高级加密标准 - Wikiwand</a></p>
<p><a target="_blank" rel="noopener" href="https://www.cnblogs.com/Amd794/p/18153705">深入理解高级加密标准（Advanced Encryption Standard） - Amd794 - 博客园 (cnblogs.com)</a></p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/u010603798/article/details/98586594">AES加密 填充方式_aes 填充字符-CSDN博客</a></p>
<p><a target="_blank" rel="noopener" href="https://www.cnblogs.com/midea0978/articles/1437257.html">关于PKCS5Padding与PKCS7Padding的区别 - 在路上… - 博客园 (cnblogs.com)</a></p>
<p><a target="_blank" rel="noopener" href="https://www.cnblogs.com/adylee/archive/2007/09/14/893438.html">分组对称加密模式:ECB&#x2F;CBC&#x2F;CFB&#x2F;OFB缺CTR - Ady Lee - 博客园 (cnblogs.com)</a></p>
<p><a target="_blank" rel="noopener" href="https://www.cnblogs.com/starwolf/p/3365834.html">AES五种加密模式（CBC、ECB、CTR、OCF、CFB） - 月之星狼 - 博客园 (cnblogs.com)</a></p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/weixin_42272869/article/details/124278342">加密模式介绍（ECB、CBC、PCBC、CFB、OFB、CTR）-CSDN博客</a></p>
</blockquote>

    </div>

    
    
    

    <footer class="post-footer">




    <div>
        
            <div style="text-align:center;color: #ccc;font-size:14px;">
            ----------本文结束
            <i class="fas fa-fan fa-spin" style="color: #FF1493; font-size: 1rem"></i>
            感谢您的阅读----------
            </div>
        
    </div>





  
  <div class="my_post_copyright"> 
    <p><span>文章标题:</span><a href="/post/914dd50d.html">LV04-02-AES算法-01-AES算法基本原理</a></p>
    <p><span>文章作者:</span><a href="/" title="欢迎访问 《苏木》 的学习笔记">苏木</a></p>
    <p><span>发布时间:</span>2024年08月25日 - 13:47</p>
    <p><span>最后更新:</span>2025年06月14日 - 00:25</p>
    <p><span>原始链接:</span><a href="/post/914dd50d.html" title="LV04-02-AES算法-01-AES算法基本原理">https://sumumm.github.io/post/914dd50d.html</a></p>
    <p><span>许可协议:</span><i class="fab fa-creative-commons"></i> <a rel="license" href= "https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">署名-非商业性使用-禁止演绎 4.0 国际</a> 转载请保留原文链接及作者。</p>  
  </div>
  


          <div class="post-tags">
              <a href="/tags/ALPHA-LV04-%E5%8A%A0%E5%AF%86%E4%B8%8E%E8%A7%A3%E5%AF%86/" rel="tag"><i class="fa fa-tag"></i> (ALPHA)LV04-加密与解密</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/post/20cd4467.html" rel="prev" title="LV04-02-AES算法-02-AES算法实现">
                  <i class="fa fa-angle-left"></i> LV04-02-AES算法-02-AES算法实现
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/post/49c90c14.html" rel="next" title="LV04-01-加密基础-01-加密算法简介">
                  LV04-01-加密基础-01-加密算法简介 <i class="fa fa-angle-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">

  <div class="copyright">
    &copy; 2017 – 
    <span itemprop="copyrightYear">2025</span>
    <span class="with-love">
      <i class="fa fa-heart"></i>
    </span>
    <span class="author" itemprop="copyrightHolder">苏木</span>
  </div>
<div class="wordcount">
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-line"></i>
    </span>
      <span>站点总字数：</span>
    <span title="站点总字数">3.7m</span>
  </span>
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span>站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">225:26</span>
  </span>
</div>




    <span id="sitetime"></span>
    <script defer language=javascript>
        function siteTime()
        {
            window.setTimeout("siteTime()", 1000);
            var seconds = 1000;
            var minutes = seconds * 60;
            var hours = minutes * 60;
            var days = hours * 24;
            var years = days * 365;
            var today = new Date();
            var todayYear = today.getFullYear();
            var todayMonth = today.getMonth()+1;
            var todayDate = today.getDate();
            var todayHour = today.getHours();
            var todayMinute = today.getMinutes();
            var todaySecond = today.getSeconds();
            /*==================================================
            Date.UTC() -- 返回date对象距世界标准时间(UTC)1970年1月1日午夜之间的毫秒数(时间戳)
            year        - 作为date对象的年份，为4位年份值
            month       - 0-11之间的整数，做为date对象的月份
            day         - 1-31之间的整数，做为date对象的天数
            hours       - 0(午夜24点)-23之间的整数，做为date对象的小时数
            minutes     - 0-59之间的整数，做为date对象的分钟数
            seconds     - 0-59之间的整数，做为date对象的秒数
            microseconds - 0-999之间的整数，做为date对象的毫秒数
            ==================================================*/
            var t1 = Date.UTC(2017, 
                              5, 
                              19, 
                              0, 
                              0, 
                              0); //北京时间
            var t2 = Date.UTC(todayYear,todayMonth,todayDate,todayHour,todayMinute,todaySecond);
            var diff = t2-t1;
            var diffYears = Math.floor(diff/years);
            var diffDays = Math.floor((diff/days)-diffYears*365);
            var diffHours = Math.floor((diff-(diffYears*365+diffDays)*days)/hours);
            var diffMinutes = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours)/minutes);
            var diffSeconds = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours-diffMinutes*minutes)/seconds);
            document.getElementById("sitetime").innerHTML="已在这里 "+diffYears+" 年 "+diffDays+" 天 "+diffHours+" 小时 "+diffMinutes+" 分钟 "+diffSeconds+" 秒";
        }
        siteTime();
    </script>



    </div>
  </footer>

  
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up fa-lg"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/next-theme-pjax/0.6.0/pjax.min.js" integrity="sha256-vxLn1tSKWD4dqbMRyv940UYw4sXgMtYcK6reefzZrao=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.umd.js" integrity="sha256-ytMJGN3toR+a84u7g7NuHm91VIR06Q41kMWDr2pq7Zo=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/lozad.js/1.16.0/lozad.min.js" integrity="sha256-mOFREFhqmHeQbXpK2lp4nA3qooVgACfh88fpJftLBbc=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script><script src="/js/pjax.js"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-generator-searchdb/1.4.1/search.js" integrity="sha256-1kfA5uHPf65M5cphT2dvymhkuyHPQp5A53EGZOnOLmc=" crossorigin="anonymous"></script>
<script src="/js/third-party/search/local-search.js"></script>




  <script src="/js/third-party/fancybox.js"></script>

  <script src="/js/third-party/pace.js"></script>


  




  

  <script class="next-config" data-name="enableMath" type="application/json">true</script><script class="next-config" data-name="mathjax" type="application/json">{"enable":true,"tags":"none","js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js","integrity":"sha256-MASABpB4tYktI2Oitl4t+78w/lyA+D7b/s9GEP0JOGI="}}</script>
<script src="/js/third-party/math/mathjax.js"></script>


 
        <div id="click-show-text"
            data-mobile = false
            data-text = 富强,民主,文明,和谐,自由,平等,公正,法制,爱国,敬业,诚信,友善
            data-fontsize = 15px
            data-random= false>
        </div>
       

      
        <script async src=https://cdn.jsdelivr.net/npm/hexo-next-mouse-effect@latest/click/showText.js></script>
      

      
    




    <script async src="/js/fancybox_param.js"></script>





<!-- APlayer本体 -->



</body>
</html>
